<template>
  <div class="app-container">
    <div class="filter-container">
      <el-input v-model="listQuery.userName" style="width: 200px;" class="filter-item" placeholder="操作人姓名" @keyup.enter.native="handleFilter"/>
      <el-button class="filter-item" type="primary" icon="search" @click="handleFilter">搜索</el-button>
    </div>
    <el-table v-loading.body="listLoading" :key="tableKey" :data="list" border fit highlight-current-row style="max-width:1200px;">
      <el-table-column min-width="8%" align="center" label="id" >
        <template slot-scope="scope">
          <span>{{ scope.row.logId }}</span>
        </template>
      </el-table-column>
      <el-table-column min-width="10%" align="center" label="模块"><template slot-scope="scope">
        <span>
          {{ scope.row.module }}</span>
      </template>

      </el-table-column>
      <el-table-column min-width="12%" align="center" label="操作"><template slot-scope="scope">
        <span>
          {{ scope.row.logDesc }}</span>
      </template>

      </el-table-column>
      <el-table-column min-width="12%" align="center" label="资源路径"><template slot-scope="scope">
        <span>
          {{ scope.row.requestUrl }}</span>
      </template>

      </el-table-column>
      <el-table-column min-width="20%" align="center" label="操作时间"><template slot-scope="scope">
        <span>
          {{ scope.row.createTime }}</span>
      </template>

      </el-table-column>
      <el-table-column min-width="12%" align="center" label="操作人ID"><template slot-scope="scope">
        <span>
          {{ scope.row.userId }}</span>
      </template>

      </el-table-column>
      <el-table-column min-width="12%" align="center" label="操作人"><template slot-scope="scope">
        <span>
          {{ scope.row.userName }}</span>
      </template>

      </el-table-column>
      <el-table-column min-width="15%" align="center" label="操作主机"><template slot-scope="scope">
        <span>
          {{ scope.row.userIp }}</span>
      </template>
      </el-table-column>
    </el-table>
    <div v-show="!listLoading" class="pagination-container">
      <el-pagination :current-page.sync="listQuery.pageNum" :page-sizes="[10,20,30, 50]" :page-size="listQuery.pageSize" :total="total" layout="total, sizes, prev, pager, next, jumper" @size-change="handleSizeChange" @current-change="handleCurrentChange"/>
    </div>
  </div>
</template>

<script>
import {
  page
} from '@/api/admin/gateLog/index'
export default {
  name: 'GateLog',
  data() {
    return {
      list: null,
      total: null,
      listLoading: true,
      listQuery: {
        pageNum: 1,
        pageSize: 20,
        crtName: undefined
      },
      dialogFormVisible: false,
      dialogStatus: '',
      gateLogManager_btn_edit: '1',
      gateLogManager_btn_del: '1',
      gateLogManager_btn_add: '1',
      textMap: {
        update: '编辑',
        create: '创建'
      },
      tableKey: 0
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.listLoading = true
      page(this.listQuery).then(response => {
        console.log('listQuery', response.data)
        this.list = response.data.list
        this.total = response.data.total
        this.listLoading = false
      }).catch((msg) => {
        this.listLoading = false
      })
    },
    handleFilter() {
      this.getList()
    },
    handleSizeChange(val) {
      this.listQuery.pageSize = val
      this.getList()
    },
    handleCurrentChange(val) {
      this.listQuery.pageNum = val
      this.getList()
    }
  }
}
</script>
